NoSQL	
  database	
  technology:	
  A	
  
survey	
  and	
  comparison	
  of	
  systems	
  

James	
  Phillips	
  

1	
  

Changes	
  in	
  interac4ve	
  so7ware	
  –	
  NoSQL	
  driver	
  

2	
  

Modern interactive software architecture 

Application Scales Out 
Just add more commodity web servers 

Database Scales Up 
Get a bigger, more complex server 

Note	
  –	
  Rela4onal	
  database	
  technology	
  is	
  great	
  for	
  what	
  it	
  is	
  great	
  for,	
  but	
  it	
  is	
  not	
  great	
  for	
  this.	
  

3	
  

Survey:	
  Schema	
  inﬂexibility	
  #1	
  adop4on	
  driver	
  

What	
  is	
  the	
  biggest	
  data	
  management	
  problem	
  	
  
driving	
  your	
  use	
  of	
  NoSQL	
  in	
  the	
  coming	
  year?	
  

Lack	
  of	
  ﬂexibility/rigid	
  schemas	
  

49%	
  

Inability	
  to	
  scale	
  out	
  data	
  

35%	
  

High	
  latency/low	
  performance	
  

29%	
  

Costs	
  

16%	
  

All	
  of	
  these	
  

12%	
  

Other	
  

11%	
  

Source: Couchbase NoSQL Survey, December 2011, n=1351 

4	
  

Extending	
  the	
  scope	
  of	
  RDBMS	
  technology	
  

•  Data	
  par44oning	
  (“sharding”)	
  

–  Disrup4ve	
  to	
  reshard	
  –	
  impacts	
  applica4on	
  
–  No	
  cross-­‐shard	
  joins	
  
–  Schema	
  management	
  on	
  every	
  shard	
  

•  Denormalizng	
  

–  Increases	
  speed	
  
–  At	
  the	
  limit,	
  provides	
  complete	
  ﬂexibility	
  
–  Eliminates	
  rela4onal	
  query	
  beneﬁts	
  

•  Distributed	
  caching	
  
–  Accelerate	
  reads	
  
–  Scale	
  out	
  
–  Another	
  4er,	
  no	
  write	
  accelera4on,	
  coherency	
  management	
  

5	
  

Lacking	
  market	
  solu4ons,	
  users	
  forced	
  to	
  invent	
  

Bigtable	
  

November	
  2006	
  

Dynamo	
  
October	
  2007	
  

Cassandra	
  

August	
  2008	
  

Voldemort	
  

February	
  2009	
  

•  No	
  schema	
  required	
  before	
  inser4ng	
  data	
  
•  No	
  schema	
  change	
  required	
  to	
  change	
  data	
  format	
  
•  Auto-­‐sharding	
  without	
  applica4on	
  par4cipa4on	
  
•  Distributed	
  queries	
  
• 
•  Data	
  synchroniza4on	
  (mobile,	
  mul4-­‐datacenter)	
  

Integrated	
  main	
  memory	
  caching	
  

Very	
  few	
  organiza4ons	
  want	
  to	
  (fewer	
  can)	
  build	
  and	
  maintain	
  database	
  so7ware	
  technology.	
  
But	
  every	
  organiza4on	
  building	
  interac4ve	
  web	
  applica4ons	
  needs	
  this	
  technology.	
  

6	
  

NoSQL database matches application logic tier architecture 
Data layer now scales with linear cost and constant performance. 

Application Scales Out 
Just add more commodity web servers 

NoSQL	
  Database	
  Servers	
  

Database Scales Out 
Just add more commodity data servers 

Scaling out flattens the cost and performance curves. 

7	
  

NOSQL	
  TAXONOMY	
  

8	
  

The Key-Value Store – the foundation of NoSQL 

Key	
  

101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
Opaque	
  
101100101000100010011101	
  
101100101000100010011101	
  
Binary	
  
101100101000100010011101	
  
101100101000100010011101	
  
Value	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  

9	
  

Memcached – the NoSQL precursor 

Key	
  

101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
Opaque	
  
101100101000100010011101	
  
101100101000100010011101	
  
Binary	
  
101100101000100010011101	
  
101100101000100010011101	
  
Value	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  

memcached	
  

In-­‐memory	
  only	
  
Limited	
  set	
  of	
  opera4ons	
  
Blob	
  Storage:	
  Set,	
  Add,	
  Replace,	
  CAS	
  
Retrieval:	
  Get	
  
Structured	
  Data:	
  Append,	
  Increment	
  

“Simple	
  and	
  fast.”	
  

Challenges:	
  cold	
  cache,	
  disrup4ve	
  elas4city	
  

10	
  

Redis	
  –	
  More	
  “Structured	
  Data”	
  commands	
  

Key	
  

101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
“Data	
  Structures”	
  
101100101000100010011101	
  
Blob	
  
101100101000100010011101	
  
101100101000100010011101	
  
List	
  
101100101000100010011101	
  
101100101000100010011101	
  
Set	
  
101100101000100010011101	
  
Hash	
  
101100101000100010011101	
  
101100101000100010011101	
  
…	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  

redis	
  

In-­‐memory	
  only	
  
Vast	
  set	
  of	
  opera4ons	
  
Blob	
  Storage:	
  Set,	
  Add,	
  Replace,	
  CAS	
  
Retrieval:	
  Get,	
  Pub-­‐Sub	
  
Structured	
  Data:	
  Strings,	
  Hashes,	
  Lists,	
  Sets,	
  
Sorted	
  lists	
  

Example	
  operaOons	
  for	
  a	
  Set	
  
Add,	
  count,	
  subtract	
  sets,	
  intersec4on,	
  is	
  
member?,	
  atomic	
  move	
  from	
  one	
  set	
  to	
  
another	
  

11	
  

NoSQL	
  catalog	
  

Key-­‐Value	
  

Data	
  Structure	
  

Document	
  

Column	
  

Graph	
  

e
h
c
a
C

)
y
l
n
o
y
r
o
m
e
m

(

memcached	
  

redis	
  

12	
  

	
  
	
  
	
  
Membase	
  –	
  From	
  key-­‐value	
  cache	
  to	
  database	
  

Key	
  

101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
Opaque	
  
101100101000100010011101	
  
101100101000100010011101	
  
Binary	
  
101100101000100010011101	
  
101100101000100010011101	
  
Value	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  
101100101000100010011101	
  

membase	
  

Disk-­‐based	
  with	
  built-­‐in	
  memcached	
  cache	
  
Cache	
  reﬁll	
  on	
  restart	
  
Memcached	
  compa4ble	
  (drop	
  in	
  replacement)	
  
Highly-­‐available	
  (data	
  replica4on)	
  
Add	
  or	
  remove	
  capacity	
  to	
  live	
  cluster	
  

“Simple,	
  fast,	
  elas4c.”	
  

13	
  

NoSQL	
  catalog	
  

Key-­‐Value	
  

Data	
  Structure	
  

Document	
  

Column	
  

Graph	
  

memcached	
  

redis	
  

membase	
  

e
h
c
a
C

)
y
l
n
o
y
r
o
m
e
m

(

e
s
a
b
a
t
a
D

)
k
s
i
d
/
y
r
o
m
e
m

(

14	
  

	
  
	
  
	
  
	
  
	
  
Couchbase	
  –	
  document-­‐oriented	
  database	
  

Key	
  

{	
  
	
  	
  	
  	
  “string”	
  :	
  “string”,	
  
	
  	
  	
  	
  “string”	
  :	
  value,	
  
	
  	
  	
  	
  “string”	
  :	
  	
  
JSON	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  	
  “string”	
  :	
  “string”,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  “string”	
  :	
  value	
  },	
  
OBJECT	
  
	
  	
  	
  	
  “string”	
  :	
  [	
  array	
  ]	
  
(“DOCUMENT”)	
  
}	
  

Couchbase	
  

Auto-­‐sharding	
  
Disk-­‐based	
  with	
  built-­‐in	
  memcached	
  cache	
  
Cache	
  reﬁll	
  on	
  restart	
  
Memcached	
  compa4ble	
  (drop	
  in	
  replace)	
  
Highly-­‐available	
  (data	
  replica4on)	
  
Add	
  or	
  remove	
  capacity	
  to	
  live	
  cluster	
  

When	
  values	
  are	
  JSON	
  objects	
  (“documents”):	
  
Create	
  indices,	
  views	
  and	
  query	
  against	
  the	
  
views	
  

15	
  

NoSQL	
  catalog	
  

Key-­‐Value	
  

Data	
  Structure	
  

Document	
  

Column	
  

Graph	
  

memcached	
  

redis	
  

membase	
  
membase	
  

couchbase	
  

e
h
c
a
C

)
y
l
n
o
y
r
o
m
e
m

(

e
s
a
b
a
t
a
D

)
k
s
i
d
/
y
r
o
m
e
m

(

16	
  

	
  
	
  
	
  
	
  
	
  
MongoDB	
  –	
  Document-­‐oriented	
  database	
  

Key	
  

{	
  
	
  	
  	
  	
  “string”	
  :	
  “string”,	
  
	
  	
  	
  	
  “string”	
  :	
  value,	
  
	
  	
  	
  	
  “string”	
  :	
  	
  
BSON	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  	
  “string”	
  :	
  “string”,	
  
OBJECT	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  “string”	
  :	
  value	
  },	
  
	
  	
  	
  	
  “string”	
  :	
  [	
  array	
  ]	
  
(“DOCUMENT”)	
  
}	
  

MongoDB	
  

Disk-­‐based	
  with	
  in-­‐memory	
  “caching”	
  
BSON	
  (“binary	
  JSON”)	
  format	
  and	
  wire	
  protocol	
  
Master-­‐slave	
  replica4on	
  
Auto-­‐sharding	
  
Values	
  are	
  BSON	
  objects	
  
Supports	
  ad	
  hoc	
  queries	
  –	
  best	
  when	
  indexed	
  

17	
  

NoSQL	
  catalog	
  

e
h
c
a
C

)
y
l
n
o
y
r
o
m
e
m

(

e
s
a
b
a
t
a
D

)
k
s
i
d
/
y
r
o
m
e
m

(

Key-­‐Value	
  

Data	
  Structure	
  

Document	
  

Column	
  

Graph	
  

memcached	
  

redis	
  

membase	
  

couchbase	
  

mongoDB	
  

18	
  

	
  
	
  
	
  
	
  
	
  
Cassandra	
  –	
  Column	
  overlays	
  

Column	
  1	
  

Column	
  2	
  

Column	
  3	
  	
  
(not	
  present)	
  	
  

Cassandra	
  

Disk-­‐based	
  system	
  
Clustered	
  	
  
External	
  caching	
  required	
  for	
  low-­‐latency	
  reads	
  
“Columns”	
  are	
  overlaid	
  on	
  the	
  data	
  
Not	
  all	
  rows	
  must	
  have	
  all	
  columns	
  
Supports	
  eﬃcient	
  queries	
  on	
  columns	
  
Restart	
  required	
  when	
  adding	
  columns	
  
Good	
  cross-­‐datacenter	
  support	
  

19	
  

NoSQL	
  catalog	
  

e
h
c
a
C

)
y
l
n
o
y
r
o
m
e
m

(

e
s
a
b
a
t
a
D

)
k
s
i
d
/
y
r
o
m
e
m

(

Key-­‐Value	
  

Data	
  Structure	
  

Document	
  

Column	
  

Graph	
  

memcached	
  

redis	
  

membase	
  

couchbase	
  

cassandra	
  

mongoDB	
  

20	
  

	
  
	
  
	
  
	
  
	
  
Neo4j	
  –	
  Graph	
  database	
  

Neo4j	
  

Disk-­‐based	
  system	
  
External	
  caching	
  required	
  for	
  low-­‐latency	
  reads	
  
Nodes,	
  rela4onships	
  and	
  paths	
  
Proper4es	
  on	
  nodes	
  
Delete,	
  Insert,	
  Traverse,	
  etc.	
  

21	
  

NoSQL	
  catalog	
  

e
h
c
a
C

)
y
l
n
o
y
r
o
m
e
m

(

e
s
a
b
a
t
a
D

)
k
s
i
d
/
y
r
o
m
e
m

(

Key-­‐Value	
  

Data	
  Structure	
  

Document	
  

Column	
  

Graph	
  

memcached	
  

redis	
  

membase	
  

couchbase	
  

cassandra	
  

Neo4j	
  

mongoDB	
  

22	
  

	
  
	
  
	
  
	
  
	
  
Document-­‐oriented	
  database	
  advantages	
  	
  

Performance.	
  The	
  document	
  data	
  model	
  keeps	
  related	
  data	
  in	
  a	
  single	
  physical	
  loca4on	
  in	
  memory	
  
and	
  on	
  disk	
  (a	
  document).	
  This	
  allows	
  consistently	
  low-­‐latency	
  access	
  to	
  the	
  data	
  –	
  reads	
  and	
  writes	
  
happen	
  with	
  very	
  liqle	
  delay.	
  Database	
  latency	
  can	
  result	
  in	
  perceived	
  “lag”	
  by	
  the	
  player	
  of	
  a	
  game	
  
and	
  avoiding	
  it	
  is	
  a	
  key	
  success	
  criterion.	
  	
  
Dynamic	
  elasOcity.	
  Because	
  the	
  document	
  approach	
  keeps	
  records	
  “in	
  one	
  place”	
  (a	
  single	
  document	
  
in	
  a	
  con4guous	
  physical	
  loca4on),	
  it	
  is	
  much	
  easier	
  to	
  move	
  the	
  data	
  from	
  one	
  server	
  to	
  another	
  while	
  
maintaining	
  consistency	
  –	
  and	
  without	
  requiring	
  any	
  game	
  down4me.	
  Moving	
  data	
  between	
  servers	
  is	
  
required	
  to	
  add	
  and	
  remove	
  cluster	
  capacity	
  to	
  cost-­‐eﬀec4vely	
  match	
  the	
  aggregate	
  performance	
  
needs	
  of	
  the	
  applica4on	
  to	
  the	
  performance	
  capability	
  of	
  the	
  database.	
  Doing	
  this	
  at	
  any	
  4me	
  without	
  
stopping	
  the	
  revenue	
  ﬂow	
  of	
  the	
  game	
  can	
  make	
  a	
  material	
  diﬀerence	
  in	
  game	
  proﬁtability.	
  
Schema	
  ﬂexibility.	
  While	
  all	
  NoSQL	
  databases	
  provide	
  schema	
  ﬂexibility.	
  Key-­‐value	
  and	
  document-­‐
oriented	
  databases	
  enjoy	
  the	
  most	
  ﬂexibility.	
  Column-­‐oriented	
  databases	
  s4ll	
  require	
  maintenance	
  to	
  
add	
  new	
  columns	
  and	
  to	
  group	
  them.	
  A	
  key-­‐value	
  or	
  document-­‐oriented	
  database	
  requires	
  no	
  
database	
  maintenance	
  to	
  change	
  the	
  database	
  schema	
  (to	
  add	
  and	
  remove	
  “ﬁelds”	
  or	
  data	
  elements	
  
from	
  a	
  given	
  record).	
  	
  
Query	
  ﬂexibility.	
  Balancing	
  schema	
  ﬂexibility	
  with	
  query	
  expressiveness	
  (the	
  ability	
  to	
  ask	
  the	
  
database	
  ques4ons,	
  for	
  example	
  “return	
  me	
  a	
  list	
  of	
  all	
  the	
  farms	
  in	
  which	
  a	
  player	
  purchased	
  a	
  black	
  
sheep	
  last	
  month”)	
  is	
  important.	
  While	
  a	
  key-­‐value	
  database	
  is	
  completely	
  ﬂexible,	
  allowing	
  a	
  user	
  to	
  
put	
  any	
  desired	
  value	
  in	
  the	
  “value”	
  part	
  of	
  the	
  key-­‐value	
  pair,	
  it	
  doesn’t	
  provide	
  the	
  ability	
  to	
  ask	
  
ques4ons.	
  It	
  only	
  permits	
  accessing	
  the	
  data	
  record	
  associated	
  with	
  a	
  given	
  key.	
  I	
  can	
  ask	
  for	
  the	
  farm	
  
data	
  for	
  user	
  A,	
  B,	
  C	
  …	
  and	
  see	
  if	
  they	
  have	
  a	
  black	
  sheep,	
  but	
  I	
  can’t	
  ask	
  the	
  database	
  to	
  do	
  that	
  work	
  
on	
  my	
  behalf.	
  Document-­‐databases	
  provide	
  the	
  best	
  balance	
  of	
  schema	
  ﬂexibility	
  without	
  giving	
  up	
  
the	
  ability	
  to	
  do	
  sophis4cated	
  queries.	
  

23	
  

Big	
  data	
  and	
  NoSQL	
  –	
  Hadoop	
  and	
  Couchbase	
  

40	
  milliseconds	
  to	
  respond	
  
with	
  the	
  decision.	
  

3	
  

proﬁles,	
  real	
  4me	
  campaign	
  	
  
sta4s4cs	
  

1	
  
click	
  stream	
  
events	
  

2	
  

proﬁles,	
  campaigns	
  

24	
  

COUCHBASE	
  

25	
  

Couchbase	
  Server	
  

Simple.	
  Fast.	
  Elas4c.	
  NoSQL.	
  	
  

	
  Couchbase	
  automa4cally	
  distributes	
  data	
  across	
  commodity	
  servers.	
  Built-­‐in	
  caching	
  enables	
  
apps	
  to	
  read	
  and	
  write	
  data	
  with	
  sub-­‐millisecond	
  latency.	
  And	
  with	
  no	
  schema	
  to	
  manage,	
  
Couchbase	
  eﬀortlessly	
  accommodates	
  changing	
  data	
  management	
  requirements.	
  	
  

26	
  

Representa4ve	
  user	
  list	
  

27	
  

Typical	
  Couchbase	
  produc4on	
  environment	
  

ApplicaOon	
  users	
  

Load	
  Balancer	
  

ApplicaOon	
  Servers	
  

Servers	
  

28	
  

Couchbase	
  architecture	
  

Database	
  Opera4ons	
  

(built-­‐in	
  memcached)	
  

I

U
b
e
W

Membase	
  EP	
  Engine	
  
Data	
  Manager	
  

storage	
  interface	
  

/
I
P
A
t
n
e
m
e
g
a
n
a
m
T
S
E
R

t
a
e
b
t
r
a
e
H

r
o
t
i
n
o
m

s
s
e
c
o
r
P

r
e
g
a
n
a
m
n
o
4
a
r
u
g
ﬁ
n
o
C

r
o
s
i
v
r
e
p
u
s
n
o
t
e
g
n
i
s

l

a
b
o
G

l

Cluster	
  Manager	
  

l

l

r
o
t
a
r
t
s
e
h
c
r
o
e
c
n
a
a
b
e
R

r
o
t
i
n
o
m
h
t
l
a
e
h
e
d
o
N

r
e
g
a
n
a
m
n
o
4
a
c
i
l

p
e
r
d
n
a
e
t
a
t
s

t
e
k
c
u
B
v

CouchDB	
  

hqp	
  

on	
  each	
  node	
  

one	
  per	
  cluster	
  

Erlang/OTP	
  

Cluster	
  Management	
  

29	
  

	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
Couchbase	
  deployment	
  

Web	
  
Applica4on	
  

Couchbase	
  
Client	
  Library	
  

Data	
  Flow	
  

Cluster	
  Management	
  

30	
  

Clustering	
  With	
  Couchbase	
  

SET	
  request	
  arrives	
  at	
  KEY’s	
  
master	
  server	
  

1	
  

2	
  

SET	
  acknowledgement	
  
returned	
  to	
  applica4on	
  

3	
  

Listener-­‐Sender	
  

RAM	
  

Disk
 Disk

Disk

Disk
 Disk

Disk

3	
  

4	
  

i

e
n
g
n
e
e
g
a
r
o
t
s
e
s
a
b
h
c
u
o
C

Replica	
  Server	
  1	
  for	
  KEY	
  

Master	
  server	
  for	
  KEY	
  

Replica	
  Server	
  2	
  for	
  KEY	
  

31	
  

	
  
	
  
	
  
Basic	
  Opera4on	
  

APP	
  SERVER	
  1	
  

APP	
  SERVER	
  2	
  

COUCHBASE	
  CLIENT	
  LIBRARY	
  

COUCHBASE	
  CLIENT	
  LIBRARY	
  

CLUSTER	
  MAP	
  

CLUSTER	
  MAP	
  

Read/Write/Update	
  

Read/Write/Update	
  

SERVER	
  1	
  

Ac4ve	
  Docs	
  

Doc	
  5	
  

Doc	
  2	
  

Doc	
  9	
  

Replica	
  Docs	
  

Doc	
  4	
  

Doc	
  1	
  

Doc	
  8	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

SERVER	
  2	
  

Ac4ve	
  Docs	
  

Doc	
  4	
  

Doc	
  7	
  

Doc	
  8	
  

Replica	
  Docs	
  

Doc	
  6	
  

Doc	
  3	
  

Doc	
  2	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

SERVER	
  3	
  

Ac4ve	
  Docs	
  

Doc	
  1	
  

Doc	
  3	
  

Doc	
  6	
  

Replica	
  Docs	
  

Doc	
  7	
  

Doc	
  9	
  

Doc	
  5	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

 Docs	
  distributed	
  evenly	
  across	
  

servers	
  in	
  the	
  cluster	
  

 Each	
  server	
  stores	
  both	
  ac#ve	
  

&	
  replica	
  docs	
  
  Only	
  one	
  server	
  ac4ve	
  at	
  a	
  4me	
  

 Client	
  library	
  provides	
  app	
  with	
  
simple	
  interface	
  to	
  database	
  
 Cluster	
  map	
  provides	
  map	
  to	
  

which	
  server	
  doc	
  is	
  on	
  
  App	
  never	
  needs	
  to	
  know	
  

  App	
  reads,	
  writes,	
  updates	
  

docs	
  

  Mul4ple	
  App	
  Servers	
  can	
  

access	
  same	
  document	
  at	
  same	
  
4me	
  

COUCHBASE	
  SERVER	
  	
  CLUSTER	
  

User	
  Conﬁgured	
  Replica	
  Count	
  =	
  1	
  

32	
  

Add	
  Nodes	
  

APP	
  SERVER	
  1	
  

APP	
  SERVER	
  2	
  

COUCHBASE	
  CLIENT	
  LIBRARY	
  

COUCHBASE	
  CLIENT	
  LIBRARY	
  

CLUSTER	
  MAP	
  

CLUSTER	
  MAP	
  

Read/Write/Update	
  

Read/Write/Update	
  

  Two	
  servers	
  added	
  to	
  

cluster	
  
  One-­‐click	
  opera4on	
  

  Docs	
  automa4cally	
  
rebalanced	
  across	
  
cluster	
  
  Even	
  distribu4on	
  of	
  

docs	
  

  Minimum	
  doc	
  
movement	
  
  Cluster	
  map	
  updated	
  

SERVER	
  1	
  

Ac4ve	
  Docs	
  

Doc	
  5	
  

Doc	
  2	
  

Doc	
  9	
  

Replica	
  Docs	
  

Doc	
  4	
  

Doc	
  1	
  

Doc	
  8	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

SERVER	
  2	
  

Ac4ve	
  Docs	
  

Doc	
  4	
  

Doc	
  7	
  

Doc	
  8	
  

Replica	
  Docs	
  

Doc	
  6	
  

Doc	
  3	
  

Doc	
  2	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

SERVER	
  3	
  

Ac4ve	
  Docs	
  

Ac4ve	
  Docs	
  

Doc	
  1	
  

Doc	
  3	
  

DOC	
  

Doc	
  3	
  

Doc	
  6	
  

DOC	
  

Doc	
  6	
  

DOC	
  

Replica	
  Docs	
  

Replica	
  Docs	
  

Doc	
  7	
  

Doc	
  7	
  

DOC	
  

Doc	
  9	
  

Doc	
  9	
  

DOC	
  

Doc	
  5	
  

DOC	
  

SERVER	
  4	
  

Ac4ve	
  Docs	
  

SERVER	
  5	
  

Ac4ve	
  Docs	
  

  App	
  database	
  calls	
  now	
  
distributed	
  over	
  larger	
  #	
  
of	
  servers	
  

Replica	
  Docs	
  

Replica	
  Docs	
  

COUCHBASE	
  SERVER	
  	
  CLUSTER	
  

User	
  Conﬁgured	
  Replica	
  Count	
  =	
  1	
  

33	
  

Fail	
  Over	
  Node	
  

APP	
  SERVER	
  1	
  

APP	
  SERVER	
  2	
  

COUCHBASE	
  CLIENT	
  LIBRARY	
  

COUCHBASE	
  CLIENT	
  LIBRARY	
  

CLUSTER	
  MAP	
  

CLUSTER	
  MAP	
  

  App	
  servers	
  happily	
  accessing	
  docs	
  

on	
  Server	
  3	
  
  Server	
  fails	
  
  App	
  server	
  requests	
  to	
  server	
  3	
  fail	
  
  Cluster	
  detects	
  server	
  has	
  failed	
  

  Promotes	
  replicas	
  of	
  docs	
  to	
  ac#ve	
  
  Updates	
  cluster	
  map	
  

  App	
  server	
  requests	
  for	
  docs	
  now	
  

go	
  to	
  appropriate	
  server	
  

  Typically	
  rebalance	
  	
  would	
  follow	
  

SERVER	
  1	
  

Ac4ve	
  Docs	
  

SERVER	
  2	
  

Ac4ve	
  Docs	
  

Doc	
  5	
  

Doc	
  2	
  

DOC	
  

DOC	
  

Doc	
  4	
  

Doc	
  7	
  

Replica	
  Docs	
  

Replica	
  Docs	
  

Doc	
  4	
  

Doc	
  1	
  

DOC	
  

DOC	
  

Doc	
  6	
  

Doc	
  3	
  

SERVER	
  3	
  

Ac4ve	
  Docs	
  

Ac4ve	
  Docs	
  

Doc	
  1	
  

Doc	
  3	
  

DOC	
  

Doc	
  3	
  

Doc	
  6	
  

Replica	
  Docs	
  

Replica	
  Docs	
  

Doc	
  7	
  

Doc	
  7	
  

DOC	
  

Doc	
  9	
  

Doc	
  9	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

DOC	
  

SERVER	
  4	
  

Ac4ve	
  Docs	
  

SERVER	
  5	
  

Ac4ve	
  Docs	
  

Doc	
  9	
  

DOC	
  

Doc	
  6	
  

Doc	
  8	
  

DOC	
  

DOC	
  

Replica	
  Docs	
  

Replica	
  Docs	
  

Doc	
  5	
  

DOC	
  

Doc	
  8	
  

DOC	
  

Doc	
  2	
  

DOC	
  

COUCHBASE	
  SERVER	
  	
  CLUSTER	
  

User	
  Conﬁgured	
  Replica	
  Count	
  =	
  1	
  

34	
  

COUCHBASE	
  SOLUTION	
  
OPERATING	
  A	
  CLUSTER	
  

35	
  

Reading	
  and	
  Wri4ng	
  

Reading	
  Data	
  

WriOng	
  Data	
  

Give	
  me	
  
document	
  A	
  

A	
  

Please	
  store	
  
document	
  A	
  

Here	
  is	
  	
  
document	
  A	
  

Server	
  

A	
  

OK,	
  I	
  stored	
  
document	
  A	
  

Server	
  

(We’ll	
  save	
  the	
  arithmeOc	
  for	
  the	
  sizing	
  secOon	
  :	
  )	
  

36	
  

Reading	
  data	
  

Give	
  me	
  document	
  A	
  

Here	
  is	
  document	
  A	
  

A	
  

A	
  

If	
  document	
  A	
  is	
  in	
  memory	
  
	
  	
  	
  	
  return	
  document	
  A	
  to	
  the	
  applica4on	
  
Else	
  
	
  	
  	
  	
  add	
  document	
  to	
  read	
  queue	
  
	
  	
  	
  	
  reader	
  eventually	
  loads	
  document	
  	
  
	
  	
  	
  	
  	
  	
  	
  from	
  disk	
  into	
  memory	
  
	
  	
  	
  	
  return	
  document	
  A	
  to	
  the	
  applica4on	
  
Server	
  

Reading	
  Data	
  

37	
  

Keeping	
  working	
  data	
  set	
  in	
  RAM	
  is	
  key	
  to	
  read	
  performance	
  

Your	
  applicaOon’s	
  working	
  
set	
  should	
  ﬁt	
  in	
  RAM…	
  

…	
  or	
  else!	
  (because	
  you	
  don’t	
  want	
  the	
  “else”	
  part	
  happening	
  very	
  
ohen	
  –	
  it	
  is	
  MUCH	
  slower	
  than	
  a	
  memory	
  read	
  and	
  you	
  could	
  have	
  to	
  
wait	
  in	
  line	
  an	
  indeterminate	
  amount	
  of	
  Ome	
  for	
  the	
  read	
  to	
  happen.)	
  

Reading	
  Data	
  

38	
  

Working	
  set	
  ra4o	
  depends	
  on	
  your	
  applica4on	
  

working/total	
  set	
  =	
  .01	
  

working/total	
  set	
  =	
  .33	
  

working/total	
  set	
  =	
  1	
  

Server	
  

Server	
  

Server	
  

Late	
  stage	
  social	
  game	
  
Many	
  users	
  no	
  longer	
  
ac4ve;	
  few	
  logged	
  in	
  at	
  
any	
  given	
  4me.	
  

Business	
  applicaOon	
  
Users	
  logged	
  in	
  during	
  the	
  
day.	
  Day	
  moves	
  around	
  
the	
  globe.	
  

Ad	
  Network	
  
Any	
  cookie	
  can	
  show	
  up	
  
at	
  any	
  4me.	
  

Reading	
  Data	
  

39	
  

Couchbase	
  in	
  opera4on:	
  Wri4ng	
  data	
  

Store	
  document	
  A	
  

OK,	
  it	
  is	
  stored	
  

A	
  

A	
  

If	
  there	
  is	
  room	
  for	
  the	
  document	
  in	
  RAM	
  
	
  	
  	
  	
  Store	
  the	
  document	
  in	
  RAM	
  
Else	
  
	
  	
  	
  	
  Eject	
  other	
  document(s)	
  from	
  RAM	
  
	
  	
  	
  	
  Store	
  the	
  document	
  in	
  RAM	
  
Add	
  the	
  document	
  to	
  the	
  replica4on	
  queue	
  
	
  	
  	
  	
  Replicator	
  eventually	
  transmits	
  document	
  
Add	
  the	
  document	
  to	
  write	
  queue	
  
	
  	
  	
  	
  Writer	
  eventually	
  writes	
  document	
  to	
  disk	
  

Server	
  

WriOng	
  Data	
  

40	
  

Flow	
  of	
  data	
  when	
  wri4ng	
  

ApplicaOons	
  wriOng	
  to	
  Couchbase	
  	
  

Server	
  

Couchbase	
  transmijng	
  replicas	
  

Couchbase	
  wriOng	
  to	
  disk	
  

network	
  

WriOng	
  Data	
  

41	
  

Queues	
  build	
  if	
  aggregate	
  arrival	
  rate	
  exceeds	
  drain	
  rates	
  

Server	
  

ReplicaOon	
  queue	
  

Disk	
  write	
  queue	
  

network	
  

WriOng	
  Data	
  

42	
  

Scaling	
  out	
  permits	
  matching	
  of	
  aggregate	
  ﬂow	
  rates	
  so	
  
queues	
  do	
  not	
  grow	
  

Server	
  

Server	
  

Server	
  

network	
  

network	
  

network	
  

43	
  

QUESTIONS?	
  

JAMES@COUCHBASE.COM	
  

44	
  

